<h1 class="titulo">
    <a href="<?php echo $this->urlbase.'/index/index';?>#st-lk-tp"><?php echo $this->segmento->CTS_NOM; ?></a>
    &rsaquo;
    <a href="<?php echo $this->urlbase.'/index/index/cat/'.$this->categoria['CAT_ID'];?>#st-lk-tp"><?php echo $this->categoria['CAT_NOM']; ?></a>
    &rsaquo;
    <?php echo $this->result['PRO_NOM']; ?>
</h1>
<div class="cnt-texto">
    <div class="det-produto">
        <div class="prm">
            <?php $img = glob('public/upload/produto/'.$this->result['PRO_ID'].'_*_dp.*'); ?>
            <img id="zoom" src="<?php echo $this->urlbase.'/'.$img[0]; ?>" data-zoom-image="<?php echo $this->urlbase.'/'.str_replace('_dp','_1z',$img[0]); ?>" />
        </div>
        <div class="seg">
            <?php
                $imgs_dl = glob('public/upload/produto/'.$this->result['PRO_ID'].'_*_dl.*');
            ?>
            <ul id="galeria" class="list-pro-lat">
                <?php foreach($imgs_dl as $img) { ?>
                <li class="clk_img">
                    <a href="#" data-image="<?php echo $this->urlbase.'/'.str_replace('_dl','_dp',$img); ?>" data-zoom-image="<?php echo $this->urlbase.'/'.str_replace('_dl','_1z',$img); ?>">
                        <img src="<?php echo $this->urlbase.'/'.$img; ?>"  />
                    </a>
                </li>
                <?php } ?>
            </ul>
        </div>
	
        <div class="info">
            <form id="form" method="post" action="">
                <input type="hidden" name="id" value="<?php echo $this->result['PRO_ID']; ?>" />
                
                <h3>Cód: <?php echo $this->result['PRO_ID']; ?></h3>
            
                <p><?php echo $this->result['PRO_DES']; ?></p>
                
                <?php if($this->material['MAT_COM1'] > '' || $this->material['MAT_COM2'] > '' || $this->material['MAT_COM3'] > '') { ?>
                <h3>Composição</h3>
                <p>
                    <?php if($this->material['MAT_COM1'] > '') echo $this->material['MAT_COM1'].'<br>'; ?>
                    <?php if($this->material['MAT_COM2'] > '') echo $this->material['MAT_COM2'].'<br>'; ?>
                    <?php if($this->material['MAT_COM3'] > '') echo $this->material['MAT_COM3'].'<br>'; ?>
                </p>
                <?php } ?>
                
                <?php if($this->modelagem['MDL_NOM'] > ''){ ?>
                <h3>Modelagem</h3>
                <p><?php echo $this->modelagem['MDL_NOM']; ?></p>
                <?php } ?>
                
                <h3>Selecione a Cor</h3>
                <ul class="grade cnt-gra-sel-cores">
                <?php foreach($this->cores as $cor) { 
                    $img = glob('public/upload/cor/'.$cor['COR_ID'].'.*');
                    if(!isset($img[0]) && strlen($cor['COR_COR']) > 0) { ?>
                        <li style="background-color: #<?php echo $cor['COR_COR']; ?>" title="<?php echo $cor['COR_NOM']; ?>"></li>
                    <?php } elseif(isset($img[0])) { ?>
                    <li title="<?php echo $cor['COR_NOM']; ?>">
                        <img src="<?php echo $this->urlbase.'/'.$img[0]; ?>" title="<?php echo $cor['COR_NOM']; ?>" />
                        <input type="radio" class="ckd_cor" name="cor" value="<?php echo $cor['COR_ID']; ?>" />
                    </li>
                    <?php } ?>
                <?php } ?>
                </ul>
                <?php if($this->segmento->CTS_ID <> 1){ ?>
                <div class="cnt_elm">
                    <a href="javascript:void(0)" class="ver_outras_cores">Ver outras cores (sob consulta)</a>
                    <div class="outras_cores">
                        <ul class="grade cnt-gra-sel-cores">
                        <?php foreach($this->coressec as $cor) { 
                          $img = glob('public/upload/cor/'.$cor['COR_ID'].'.*');
                          if(!isset($img[0]) && strlen($cor['COR_COR']) > 0) { ?>
                              <li style="background-color: #<?php echo $cor['COR_COR']; ?>" title="<?php echo $cor['COR_NOM']; ?>"></li>
                          <?php } elseif(isset($img[0])) { ?>
                          <li title="<?php echo $cor['COR_NOM']; ?>">
                              <img src="<?php echo $this->urlbase.'/'.$img[0]; ?>" title="<?php echo $cor['COR_NOM']; ?>" />
                              <input type="radio" class="ckd_cor" name="cor" value="<?php echo $cor['COR_ID']; ?>" />
                          </li>
                          <?php } ?>
                        <?php } ?>
                        </ul>  
                    </div>
                </div>
                <?php } ?>
                <?php if(count($this->coresdet) > 0){ ?>
                <h3>Selecione a Cor Detalhe</h3>
                <ul class="gradedet cnt-gra-sel-cores-det">
                <?php foreach($this->coresdet as $cordet) { 
                    $img = glob('public/upload/cordetalhe/'.$cordet['CRD_ID'].'.*');
                    if(!isset($img[0]) && strlen($cordet['CRD_COR']) > 0) { ?>
                        <li style="background-color: #<?php echo $cor['CRD_COR']; ?>" title="<?php echo $cordet['CRD_NOM']; ?>"></li>
                    <?php } elseif(isset($img[0])) { ?>
                    <li title="<?php echo $cordet['CRD_NOM']; ?>">
                        <img src="<?php echo $this->urlbase.'/'.$img[0]; ?>" title="<?php echo $cordet['CRD_NOM']; ?>" />
                        <input type="checkbox" class="ckd_cor" name="cor_det[]" value="<?php echo $cordet['CRD_ID']; ?>" />
                    </li>
                    <?php } ?>
                <?php } ?>
                </ul>
                <?php } ?>
                
                <h3>Selecione o Tamanho</h3>
                <ul class="grade tam">
                    <?php foreach($this->tamanho as $tam) { 
                        $query = 'SELECT SQL_CACHE TAM_ID,TAM_NOM,TAM_DES FROM TAMANHOS WHERE TAM_ID = '. $tam['TAM_ID'];
                        $tm = $this->db->fetchRow($query);
                    ?>
                    <li title="<?php echo $tm['TAM_DES']; ?>">
                        <?php echo $tm['TAM_NOM']; ?>
                        <input type="checkbox" class="ckd_tam" name="tam[]" value="<?php echo $tam['TAM_ID']; ?>" />
                    </li>
                    <?php } ?> 
                </ul>
                <h3>Quantidade</h3>
                <input type="text" id="qtd" name="qtd" class="qtd" value="" maxlength="4" /> <?php if($this->result['PRO_QTDMIN'] > 0) echo '<span class="minqtd">* Mínimo '.$this->result['PRO_QTDMIN'].' peças</span>'; ?>

                <a href="javascript:void(0)" onclick="$('#form').submit()" class="solitar-orc">Solicitar Orçamento</a>
                <a href="<?php echo $this->urlbase;?>/forma" class="ver-forma">Ver Formas de Pagamento</a>
            </form>
        </div>
        
	<div class="tab_tam">
		<h3>Tabela de Tamanhos</h3>
		<?php
		    $img_tab = glob('public/upload/gradetamanhos/'.$this->result['GRA_ID'].'_tabtam.*'); 
		    if(isset($img_tab[0])){ 
		?>
		<img src="<?php echo $this->urlbase.'/'.$img_tab[0]; ?>" width="200" height="200" />
		<?php } ?>

		<table>
		    <thead>
		
			<tr>
			    <th>Tam.</th>
			    <?php foreach($this->leg as $key => $led){  
				$query = 'SELECT SQL_CACHE LGM_ID,LGM_NOM FROM LEGENDAMEDIDAS WHERE LGM_ID = ' . $led['LGM_ID'];
                                $lgm = $this->db->fetchRow($query);
                                $arr_col[$key] = $led['LGM_ID'];
			    ?>
				<th><?php echo $lgm['LGM_NOM']; ?></th>
			    <?php } ?>
			</tr>
		
		    </thead>
		    <tbody>
			<?php 
			    foreach($this->tam as $tm){ 
                                $query = 'SELECT SQL_CACHE * FROM TAMANHOS WHERE TAM_ID = ' . $tm['TAM_ID'];
                                $tam = $this->db->fetchRow($query);
			?>
			<tr>
			     <td><?php echo $tam['TAM_NOM']; ?></td>
			    <?php foreach($arr_col as $col){ 
				$query = 'SELECT SQL_CACHE GTM_VAL FROM GRADETAMANHOS_HAS_MEDIDAS WHERE GRA_ID = '.$this->result['GRA_ID'].' and TAM_ID = '.$tm['TAM_ID'].' and LGM_ID = '.$col;
                                $r_gtm = $this->db->fetchRow($query);
                            ?>
			    <td><?php echo $r_gtm['GTM_VAL']; ?></td>
			    <?php } ?>
			</tr>
			<?php } ?>
		    </tbody>   
		</table>                
	</div>
        
        <?php if($this->result['GRA_ID2'] > 0){ ?>
        <div class="tab_tam" style="clear: both;margin-top:10px;">
		<?php
		    $img_tab = glob('public/upload/gradetamanhos/'.$this->result['GRA_ID2'].'_tabtam.*'); 
		    if(isset($img_tab[0])){ 
		?>
		<img src="<?php echo $this->urlbase.'/'.$img_tab[0]; ?>" width="200" height="200" />
		<?php } ?>

		<table>
		    <thead>
		
			<tr>
			    <th>Tam.</th>
			    <?php foreach($this->leg2 as $key => $led){ 
				$query = 'SELECT SQL_CACHE LGM_ID,LGM_NOM FROM LEGENDAMEDIDAS WHERE LGM_ID = ' . $led['LGM_ID'];
                                $lgm = $this->db->fetchRow($query);
                                $arr_col2[$key] = $led['LGM_ID'];
			    ?>
				<th><?php echo $lgm['LGM_NOM']; ?></th>
			    <?php } ?>
			</tr>
		
		    </thead>
		    <tbody> 
			<?php 
                        foreach($this->tam2 as $tm){ 
                            $query = 'SELECT SQL_CACHE * FROM TAMANHOS WHERE TAM_ID = ' . $tm['TAM_ID'];
                            $tam = $this->db->fetchRow($query);
			?>
			<tr>
			     <td><?php echo $tam['TAM_NOM']; ?></td>
			    <?php foreach($arr_col2 as $col){ 
                                $query = 'SELECT SQL_CACHE GTM_VAL FROM GRADETAMANHOS_HAS_MEDIDAS WHERE GRA_ID = '.$this->result['GRA_ID2'].' and TAM_ID = '.$tm['TAM_ID'].' and LGM_ID = '.$col;
                                $r_gtm = $this->db->fetchRow($query);
                            ?>
			    <td><?php echo $r_gtm['GTM_VAL']; ?></td>
			    <?php } ?>
			</tr>
			<?php } ?>
		    </tbody>   
		</table>                
	</div>
        <?php }  ?>
        
    </div>
</div>
<div id="script"></div>
<?php/*
<script src="<?php echo $this->urlbase;?>/public/media/js/jquery.jcarousel.min.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
    $('.seg').jcarousel({
        vertical: true,
        scroll: 2
    });
}); 
</script>
*/?>
<script>
$(document).ready(function(){ <?php // zoomType : "inner", cursor: 'crosshair',  ?>
   $("#zoom").elevateZoom({ gallery:'galeria', galleryActiveClass: 'active', imageCrossfade: true, scrollZoom : true, loadingIcon: '<?php echo $this->urlbase;?>/public/media/images/loader_bg.gif' }); 
   $("#zoom").bind("click", function(e) {  var ez =   $('#zoom').data('elevateZoom');	$.fancybox(ez.getGalleryList()); return false; });
});
</script>
